package com.ruoyi.system.service.news.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.PageHelper;
import com.ruoyi.system.domain.news.NewsAssessArchive;
import com.ruoyi.system.domain.news.query.NewsAssessArchiveQuery;
import com.ruoyi.system.domain.news.vo.NewsAssessArchiveVo;
import com.ruoyi.system.domain.news.vo.NewsAssessArchiveVo;
import com.ruoyi.system.mapper.news.NewsAssessArchiveMapper;
import com.ruoyi.system.service.news.NewsAssessArchiveService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
@Slf4j
public class NewsAssessArchiveServiceImpl extends ServiceImpl<NewsAssessArchiveMapper, NewsAssessArchive>
        implements NewsAssessArchiveService {

    @Override
//    @DataScope(deptAlias = "t",userAlias = "t")
    public List<NewsAssessArchiveVo> getNewsAssessArchiveList(NewsAssessArchiveQuery newsAssessArchiveQuery) {
        if (newsAssessArchiveQuery.getIfPage()) {
            PageHelper.startPage(newsAssessArchiveQuery.getPageNum(), newsAssessArchiveQuery.getPageSize());
        }
        List<NewsAssessArchiveVo> newsAssessArchiveVoList = baseMapper.getNewsAssessArchiveList(newsAssessArchiveQuery);
        if (!newsAssessArchiveVoList.isEmpty() && newsAssessArchiveQuery.getId() == null) {
            for (NewsAssessArchiveVo newsAssessArchiveVo:newsAssessArchiveVoList) {
                newsAssessArchiveVo.setContent(null);
            }
        }
        return newsAssessArchiveVoList;
    }
}
